package de.thwildau.tm.moses.asn1.serializer;

import com.google.inject.Inject;
import de.thwildau.tm.moses.asn1.services.Asn1GrammarAccess;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.AlternativeAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.GroupAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.TokenAlias;
import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynNavigable;
import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition;
import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer;

@SuppressWarnings("all")
public class Asn1SyntacticSequencer extends AbstractSyntacticSequencer {

	protected Asn1GrammarAccess grammarAccess;
	protected AbstractElementAlias match_ChoiceType_ExtensionMarkerParserRuleCall_4_3_q;
	protected AbstractElementAlias match_ElementSetSpecs___CommaKeyword_1_0_FullStopFullStopFullStopKeyword_1_1__q;
	protected AbstractElementAlias match_Intersections_CircumflexAccentKeyword_1_0_0_or_INTERSECTIONKeyword_1_0_1;
	protected AbstractElementAlias match_NamedComponentType_OPTIONALKeyword_1_0_q;
	protected AbstractElementAlias match_SequenceType_CommaKeyword_4_q;
	protected AbstractElementAlias match_SequenceType_ExtensionMarkerParserRuleCall_5_2_q;
	protected AbstractElementAlias match_SetType_ExtensionMarkerParserRuleCall_3_0_1_q;
	protected AbstractElementAlias match_Unions_UNIONKeyword_1_0_1_or_VerticalLineKeyword_1_0_0;
	
	@Inject
	protected void init(IGrammarAccess access) {
		grammarAccess = (Asn1GrammarAccess) access;
		match_ChoiceType_ExtensionMarkerParserRuleCall_4_3_q = new TokenAlias(false, true, grammarAccess.getChoiceTypeAccess().getExtensionMarkerParserRuleCall_4_3());
		match_ElementSetSpecs___CommaKeyword_1_0_FullStopFullStopFullStopKeyword_1_1__q = new GroupAlias(false, true, new TokenAlias(false, false, grammarAccess.getElementSetSpecsAccess().getCommaKeyword_1_0()), new TokenAlias(false, false, grammarAccess.getElementSetSpecsAccess().getFullStopFullStopFullStopKeyword_1_1()));
		match_Intersections_CircumflexAccentKeyword_1_0_0_or_INTERSECTIONKeyword_1_0_1 = new AlternativeAlias(false, false, new TokenAlias(false, false, grammarAccess.getIntersectionsAccess().getCircumflexAccentKeyword_1_0_0()), new TokenAlias(false, false, grammarAccess.getIntersectionsAccess().getINTERSECTIONKeyword_1_0_1()));
		match_NamedComponentType_OPTIONALKeyword_1_0_q = new TokenAlias(false, true, grammarAccess.getNamedComponentTypeAccess().getOPTIONALKeyword_1_0());
		match_SequenceType_CommaKeyword_4_q = new TokenAlias(false, true, grammarAccess.getSequenceTypeAccess().getCommaKeyword_4());
		match_SequenceType_ExtensionMarkerParserRuleCall_5_2_q = new TokenAlias(false, true, grammarAccess.getSequenceTypeAccess().getExtensionMarkerParserRuleCall_5_2());
		match_SetType_ExtensionMarkerParserRuleCall_3_0_1_q = new TokenAlias(false, true, grammarAccess.getSetTypeAccess().getExtensionMarkerParserRuleCall_3_0_1());
		match_Unions_UNIONKeyword_1_0_1_or_VerticalLineKeyword_1_0_0 = new AlternativeAlias(false, false, new TokenAlias(false, false, grammarAccess.getUnionsAccess().getUNIONKeyword_1_0_1()), new TokenAlias(false, false, grammarAccess.getUnionsAccess().getVerticalLineKeyword_1_0_0()));
	}
	
	@Override
	protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if(ruleCall.getRule() == grammarAccess.getExtensionMarkerRule())
			return getExtensionMarkerToken(semanticObject, ruleCall, node);
		else if(ruleCall.getRule() == grammarAccess.getSTRINGRule())
			return getSTRINGToken(semanticObject, ruleCall, node);
		return "";
	}
	
	/**
	 * ExtensionMarker:
	 * 	"," "..."
	 * ;
	 */
	protected String getExtensionMarkerToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if (node != null)
			return getTokenText(node);
		return ",...";
	}
	
	/**
	 * terminal STRING	: 
	 * 			'"' ( '\\' ('b'|'t'|'n'|'f'|'r'|'u'|'"'|"'"|'\\') | !('\\'|'"') )* '"'
	 * 		;
	 */
	protected String getSTRINGToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		if (node != null)
			return getTokenText(node);
		return "\"\"";
	}
	
	@Override
	protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) {
		if (transition.getAmbiguousSyntaxes().isEmpty()) return;
		List<INode> transitionNodes = collectNodes(fromNode, toNode);
		for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) {
			List<INode> syntaxNodes = getNodesFor(transitionNodes, syntax);
			if(match_ChoiceType_ExtensionMarkerParserRuleCall_4_3_q.equals(syntax))
				emit_ChoiceType_ExtensionMarkerParserRuleCall_4_3_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_ElementSetSpecs___CommaKeyword_1_0_FullStopFullStopFullStopKeyword_1_1__q.equals(syntax))
				emit_ElementSetSpecs___CommaKeyword_1_0_FullStopFullStopFullStopKeyword_1_1__q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_Intersections_CircumflexAccentKeyword_1_0_0_or_INTERSECTIONKeyword_1_0_1.equals(syntax))
				emit_Intersections_CircumflexAccentKeyword_1_0_0_or_INTERSECTIONKeyword_1_0_1(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_NamedComponentType_OPTIONALKeyword_1_0_q.equals(syntax))
				emit_NamedComponentType_OPTIONALKeyword_1_0_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_SequenceType_CommaKeyword_4_q.equals(syntax))
				emit_SequenceType_CommaKeyword_4_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_SequenceType_ExtensionMarkerParserRuleCall_5_2_q.equals(syntax))
				emit_SequenceType_ExtensionMarkerParserRuleCall_5_2_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_SetType_ExtensionMarkerParserRuleCall_3_0_1_q.equals(syntax))
				emit_SetType_ExtensionMarkerParserRuleCall_3_0_1_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_Unions_UNIONKeyword_1_0_1_or_VerticalLineKeyword_1_0_0.equals(syntax))
				emit_Unions_UNIONKeyword_1_0_1_or_VerticalLineKeyword_1_0_0(semanticObject, getLastNavigableState(), syntaxNodes);
			else acceptNodes(getLastNavigableState(), syntaxNodes);
		}
	}

	/**
	 * Syntax:
	 *     ExtensionMarker?
	 */
	protected void emit_ChoiceType_ExtensionMarkerParserRuleCall_4_3_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     (',' '...')?
	 */
	protected void emit_ElementSetSpecs___CommaKeyword_1_0_FullStopFullStopFullStopKeyword_1_1__q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     'INTERSECTION' | '^'
	 */
	protected void emit_Intersections_CircumflexAccentKeyword_1_0_0_or_INTERSECTIONKeyword_1_0_1(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     'OPTIONAL'?
	 */
	protected void emit_NamedComponentType_OPTIONALKeyword_1_0_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ','?
	 */
	protected void emit_SequenceType_CommaKeyword_4_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ExtensionMarker?
	 */
	protected void emit_SequenceType_ExtensionMarkerParserRuleCall_5_2_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ExtensionMarker?
	 */
	protected void emit_SetType_ExtensionMarkerParserRuleCall_3_0_1_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     'UNION' | '|'
	 */
	protected void emit_Unions_UNIONKeyword_1_0_1_or_VerticalLineKeyword_1_0_0(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
}
